package com.logistics.entity;

import com.logistics.pojo.Employee;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;

public class LoginUser implements UserDetails {

    //将我们自己的User对象定义在LoginUser实现类中
    private Employee employee;

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    @Override
    public String getPassword() {
        //返回用户密码
        return employee.getPassword();
    }

    public void setPassword(String pwd) {
        //返回用户密码
        employee.setPassword(pwd);
    }

    @Override
    public String getUsername() {
        return employee.getUsername();
    }

    //是否未过期
    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    //是否未锁定
    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    //凭证是否未过期
    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }
    //是否可用
    @Override
    public boolean isEnabled() {
        return true;
    }

    public LoginUser(Employee employee) {
        this.employee = employee;
    }

    public LoginUser() {
    }

    public Employee getEmployee() {
        return employee;
    }

    public void setEmployee(Employee employee) {
        this.employee = employee;
    }
}
